% function z = chebyshev_points(N)
%     k = 1:N;
%     z = -cos(k * pi / N);
% end
function x = chebyshev_points(N, a, b)
    k = 0:N-1;  % 生成索引 k
    %z = -cos(k * pi / (N-1));  % 计算标准 Chebyshev 配点（范围 [-1,1]）
    z = -cos(max(min(k * pi / (N-1), pi), 0));

    % 线性映射到范围 [a, b]
    x = (b - a) / 2 * z + (a + b) / 2;
end